<!-- http://reactiveraven.github.io/jqBootstrapValidation/ -->
<script src="<?php echo URL;?>/js/jqBootstrapValidation.js"></script>

	<h1>Formulario de Contacto</h1>

    <form id="frm_contacto" method="post" action="<?php echo URL;?>/ajax/enviar_formulario_contacto.php" class="form-horizontal">


		<div class="control-group">
			<label class="control-label" for="inputApellido">Apellido:</label>
			<div class="controls">
			  <input type="text" class='input-xlarge' name='data[apellido]' id="inputApellido" required >
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputNombre">Nombre:</label>
			<div class="controls">
			  <input type="text" class='input-xlarge' name='data[nombre]' id="inputNombre" required >
			</div>
		</div>

		<div class="control-group">
			<label class="control-label" for="inputEmail">Email:</label>
			<div class="controls">
			  <input type="email" class='input-xlarge' name='data[email]' id="inputEmail" required >
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="inputTelefono">Telefono:</label>
			<div class="controls">
			  <input type="text" class='input-xlarge' name='data[telefono]' id="inputTelefono" >
			</div>
		</div>

		<div class="control-group">
			<label class="control-label" for="inputTelefono">Comentario:</label>
			<div class="controls">
				<textarea rows='4' name='data[comentario]' id='inputComentario' placeholder='Comentario/Sugerencia' class='input-xlarge'></textarea>
				
				<div class="alert alert-success span8" id='envio_ok' style='display:none;margin-left:0px;'>
				  <button type="button" class="close" data-dismiss="alert">x</button>
				  Formulario enviado correctamente!!
				</div>
				<div class="alert alert-error span8" id='envio_error' style='display:none;margin-left:0px;'>
				  <button type="button" class="close" data-dismiss="alert">x</button>
				  <strong>ERROR!</strong> No se pudo enviar el Formulario!!
				</div>


				<input type='hidden' name='data[producto_id]' id='producto_id' value='<?php echo $Producto['id'];?>' />
				<div class='clearfix' style='margin-bottom:20px;'></div>
				<button type="submit" class="btn btn-primary btn-block span5" ><i class="icon-envelope-alt">
					</i>&nbsp;&nbsp;<?php echo $Traducciones['frm_enviar'];?>
					<img src='<?php echo URL;?>/img/loading.gif' id='img_enviado' style='display:none;float:right;margin-right:30px;'>
				</button>
				
			</div>
		</div>

	</form>	

<script type="text/javascript">
	jQuery(function () { 
		jQuery("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
		
			submitSuccess: function ($form, event) {
				jQuery('#img_enviado').show();		
				jQuery.ajax({
					type: 'POST',
					url: jQuery("#frm_contacto").attr('action'),
					data: jQuery("#frm_contacto").serialize(),
					success: function(data)
					{ 
						if(data==1){
							jQuery('#envio_ok').show();
						} else {
							jQuery('#envio_error').show();
						}
						jQuery('#img_enviado').hide();		
					}
				});

			  // will not trigger the default submission in favor of the ajax function
			  event.preventDefault();
			}

		});
	});  
</script>


<?php //pr($DatosEmpresa);?>